require 'thread'

class Squick

  # Listener thread to wait for console commands from the person
  # running the bot.
  def inputThread
    while(true)
      input = gets
      # if it starts with a / make sure it's a legit command
      if(input.match(/\/.*/)) then
        # if it's a private message
        if(input.match(/^\/msg ([^ ]*) (.*)/)) then
          sayToUser $~[1], $~[2]
        #if it's a join command
        elsif(input.match(/^\/join (#.*)/)) then
          join($~[1])
        # if you're requesting the names list
        elsif(input.match(/^\/names/)) then
          getNameList
        # if you are shutting down the bot
        elsif(input.match(/^\/(quit|exit|shutdown)$/)) then
          exit
        # refreshing the triggers and ops lists
        elsif(input.match(/^\/(refresh|reload|addons)$/)) then
         # @triggers = loadTriggers()
          loadAddons
          puts("\e[1;31mADDONS RELOADED\e[0m")
        # anything else that didn't get hit above...
        else
          puts("\e[1;31mILLEGAL COMMAND!!\e[0m")
        end
      # if it doesn't start with a / just say it to the channel
      else
        sayToChan input
      end
    end
  end

end
